<template>
  <div>
    医生服务详情
    可以查看医生的预约服务名单，未完成的服务显示为未完成，完成服务后点击已完成改状态为服务已完成，
    <div>
    <h3>患者预约列表</h3>
    <el-table :data="tableData" stripe style="width: 100%">
    <el-table-column prop="aid" label="ID" width="80" align="center"></el-table-column>
    <el-table-column prop="did" label="医生ID" width="80" align="center"></el-table-column>
    <el-table-column prop="doctor.dname" label="医生姓名" width="80" align="center"></el-table-column>
    <el-table-column prop="pid" label="患者ID" width="80" align="center"></el-table-column>
    <el-table-column prop="patient.pname" label="患者姓名" width="80" align="center"></el-table-column>

    <el-table-column prop="atime" label="预约日期" width="80" align="center"></el-table-column>
    <el-table-column prop="astate" label="预约状态" width="80" align="center"></el-table-column>
    <el-table-column
      label="操作"
      width="320">
      <template slot-scope="scope">
        <el-button @click="handleClick(scope.row)" type="success" size="big">已体检</el-button>
      </template>
    </el-table-column>
  </el-table>
  </div>
  </div>
</template>

<script>
export default {
  mounted(){
    this.appointment_init();
  },
  data(){
    return{
      tableData:[],
    }
  },
  methods:{
    // 初始化预约列表
    appointment_init(){
      //收集参数
      // 发送请求
      this.$axios.get("doctor-serv/appointment/findAllWithMsg")
      // 处理响应
      .then(resp=>{
        let r=resp.data;
        console.log(r);
        if(r.code==200){
          console.log(r.data);
          this.tableData=r.data;
          return;
        }
        this.$message.error("未知异常！")
      });
    },
    // 更改预约状态为已完成
    handleClick(row){
      this.$axios.get("doctor-serv/appointment/handle/"+row.aid)
      .then(res => {
          if(res.data.code == 200){
            this.appointment_init();
          }
      });
    }
  }
}
</script>

<style>

</style>